#define NDEBUG

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <algorithm>

using namespace std;

typedef long long int64;

#define NMAX 5000000
#define BLOCKSIZE 10000

extern int64 table[];

static int n;

static int pcnt;
static int64 prime[NMAX + 10];
static int64 phi[NMAX + 10];
static int64 miu[NMAX + 10];
static bool marked[NMAX + 10];
static void evaluate_primes() {
    marked[1] = true;
    phi[1] = 1;
    miu[1] = 1;

    for (int i = 2; i <= n; i++) {
        if (!marked[i]) {
            prime[++pcnt] = i;
            phi[i] = i - 1;
            miu[i] = -1;
        }

        for (int j = 1; j <= pcnt && prime[j] * i <= n; j++) {
            marked[prime[j] * i] = true;

            if (i % prime[j] == 0) {
                phi[prime[j] * i] = phi[i] * prime[j];
                miu[prime[j] * i] = 0;
                break;
            } else {
                phi[prime[j] * i] = phi[prime[j]] * phi[i];
                miu[prime[j] * i] = miu[prime[j]] * miu[i];
            }
        }  // for
    }      // for
}

static void initialize() {
    scanf("%d", &n);

    evaluate_primes();
}

inline int64 evaluate_f(int x) {
    int64 result = 0;

    for (int i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            if (i * i == x)
                result += phi[i] * miu[i];
            else
                result += phi[i] * miu[x / i] + phi[x / i] * miu[i];
        }
        // printf("f(%d) = %lld\n", x, result);
    }  // for

    return result;
}

int main() {
    initialize();

    int pos = n / BLOCKSIZE;
    int64 answer = table[pos];
    for (int i = pos * BLOCKSIZE + 1; i <= n; i++) {
        answer += evaluate_f(i);
    }  // for

    printf("%lld\n", answer);

    return 0;
}  // function main

int64 table[] = { 0,
                  18477109,
                  73921309,
                  166311474,
                  295651196,
                  461987848,
                  665238107,
                  905434512,
                  1182695759,
                  1496751235,
                  1847865075,
                  2235973199,
                  2660960069,
                  3122868727,
                  3621891538,
                  4157738193,
                  4730497372,
                  5340438067,
                  5987156916,
                  6670855478,
                  7391571211,
                  8149173843,
                  8943692156,
                  9775332410,
                  10643723836,
                  11549173821,
                  12491732262,
                  13471044349,
                  14487300738,
                  15540753166,
                  16630873036,
                  17758013302,
                  18922391834,
                  20123429174,
                  21361305362,
                  22636567313,
                  23948471661,
                  25297351791,
                  26683533957,
                  28106299491,
                  29565923838,
                  31062999520,
                  32596556715,
                  34167232509,
                  35775036146,
                  37419446031,
                  39100975728,
                  40819833203,
                  42575101149,
                  44367343810,
                  46197136933,
                  48063169543,
                  49966503891,
                  51907020979,
                  53884165152,
                  55898083036,
                  57949495391,
                  60037473968,
                  62162389974,
                  64324825529,
                  66523607000,
                  68759418304,
                  71032596177,
                  73342272165,
                  75688940747,
                  78073064554,
                  80493528779,
                  82951003245,
                  85446153142,
                  87977544113,
                  90545802849,
                  93151803289,
                  95793920815,
                  98473105724,
                  101189965900,
                  103943110982,
                  106733122063,
                  109561024371,
                  112424731561,
                  115325726663,
                  118264542595,
                  121239224187,
                  124251177108,
                  127300642833,
                  130386258418,
                  133508896839,
                  136669106351,
                  139865723433,
                  143099206876,
                  146370590265,
                  149678103675,
                  153022557839,
                  156404696193,
                  159822923457,
                  163278128522,
                  166771227566,
                  170300485365,
                  173866502651,
                  177470430905,
                  181110373041,
                  184787339622,
                  188502421592,
                  192253157839,
                  196041078241,
                  199866683221,
                  203728388611,
                  207627266483,
                  211563660687,
                  215536371714,
                  219546001458,
                  223593565467,
                  227676782138,
                  231797498665,
                  235955827526,
                  240150041961,
                  244381357076,
                  248650795766,
                  252955900679,
                  257297940726,
                  261678110755,
                  266094619331,
                  270547312802,
                  275038625041,
                  279565316303,
                  284129250097,
                  288731064631,
                  293368772289,
                  298043781317,
                  302756402543,
                  307505359693,
                  312290758677,
                  317114705131,
                  321973771984,
                  326870533073,
                  331805424351,
                  336775556396,
                  341783213603,
                  346828447997,
                  351909781823,
                  357027770202,
                  362184401277,
                  367376183079,
                  372605539000,
                  377872828794,
                  383175789596,
                  388516123651,
                  393893894415,
                  399308146024,
                  404758690563,
                  410247642901,
                  415772111561,
                  421333931019,
                  426933895711,
                  432569759976,
                  438242136559,
                  443953316114,
                  449699184921,
                  455482847547,
                  461304594543,
                  467161911887,
                  473055946976,
                  478988702527,
                  484956758275,
                  490961965453,
                  497005611805,
                  503084595434,
                  509200566725,
                  515354871657,
                  521544676506,
                  527771959137,
                  534036812632,
                  540337969336,
                  546675636185,
                  553052115853,
                  559463354116,
                  565911973730,
                  572399468270,
                  578920914515,
                  585480543281,
                  592078862679,
                  598712487611,
                  605382419957,
                  612091110800,
                  618835442488,
                  625616759798,
                  632436583547,
                  639291577925,
                  646183676083,
                  653114010552,
                  660079982871,
                  667082964492,
                  674124473676,
                  681201284258,
                  688315109311,
                  695467783053,
                  702654891155,
                  709879734057,
                  717143579062,
                  724441609083,
                  731777449224,
                  739151526103,
                  746561101391,
                  754006779008,
                  761492396241,
                  769012486681,
                  776569619732,
                  784165805304,
                  791796887775,
                  799465455301,
                  807171722493,
                  814913516032,
                  822692568379,
                  830510220791,
                  838363341460,
                  846252761216,
                  854182098516,
                  862145483221,
                  870146623354,
                  878186092270,
                  886260157303,
                  894371761655,
                  902522412359,
                  910707937919,
                  918930021493,
                  927191173153,
                  935488182060,
                  943820821168,
                  952193296643,
                  960600578295,
                  969044440777,
                  977527598744,
                  986045311015,
                  994600710724,
                  1003194989670,
                  1011823373287,
                  1020489095629,
                  1029194717821,
                  1037934193161,
                  1046711186005,
                  1055526987919,
                  1064376689201,
                  1073264964242,
                  1082191563027,
                  1091152542111,
                  1100151274284,
                  1109188730215,
                  1118261574854,
                  1127370338594,
                  1136519262469,
                  1145702024855,
                  1154923033251,
                  1164181494909,
                  1173475965585,
                  1182806517733,
                  1192176864591,
                  1201581732235,
                  1211023727665,
                  1220505121072,
                  1230020682294,
                  1239574166302,
                  1249165812992,
                  1258792044859,
                  1268456198816,
                  1278158991277,
                  1287897063070,
                  1297670177037,
                  1307484607078,
                  1317333302701,
                  1327218417258,
                  1337143190314,
                  1347102188701,
                  1357098736263,
                  1367134543014,
                  1377203972428,
                  1387311542890,
                  1397457920204,
                  1407638276599,
                  1417856764088,
                  1428114271523,
                  1438405983898,
                  1448735067467,
                  1459103474798,
                  1469505346026,
                  1479945589415,
                  1490424784016,
                  1500938149143,
                  1511488310716,
                  1522077960489,
                  1532702918199,
                  1543363825261,
                  1554065576742,
                  1564800992982,
                  1575573174318,
                  1586384798526,
                  1597230232411,
                  1608114089692,
                  1619036475821,
                  1629994023001,
                  1640987768124,
                  1652021751306,
                  1663089761138,
                  1674194509126,
                  1685338570929,
                  1696516725360,
                  1707732916042,
                  1718988634877,
                  1730278307280,
                  1741604618352,
                  1752970730223,
                  1764371154902,
                  1775808763811,
                  1787286036593,
                  1798797297398,
                  1810345913375,
                  1821933649645,
                  1833555863071,
                  1845215545132,
                  1856913965219,
                  1868647469425,
                  1880416498183,
                  1892226725235,
                  1904070225350,
                  1915951897141,
                  1927872477571,
                  1939827083884,
                  1951819716212,
                  1963850487148,
                  1975916964816,
                  1988018293020,
                  2000161352333,
                  2012337576258,
                  2024551476421,
                  2036805182196,
                  2049092524441,
                  2061417097143,
                  2073781063307,
                  2086179090450,
                  2098614567897,
                  2111089544128,
                  2123597749886,
                  2136145015218,
                  2148731256641,
                  2161350339520,
                  2174008784312,
                  2186705206326,
                  2199435775907,
                  2212202978225,
                  2225011135392,
                  2237852648037,
                  2250731047215,
                  2263650236333,
                  2276603617812,
                  2289591454767,
                  2302622434173,
                  2315685768639,
                  2328785825121,
                  2341927189062,
                  2355100306779,
                  2368312004253,
                  2381562839724,
                  2394847876038,
                  2408170873208,
                  2421532800153,
                  2434929309642,
                  2448362745168,
                  2461835613566,
                  2475341495048,
                  2488885500567,
                  2502470574519,
                  2516088485666,
                  2529742157848,
                  2543437512599,
                  2557166357450,
                  2570932014454,
                  2584737965082,
                  2598576476985,
                  2612454084805,
                  2626369697488,
                  2640320678773,
                  2654308026740,
                  2668335052268,
                  2682396903198,
                  2696495201314,
                  2710633630564,
                  2724805721950,
                  2739014533208,
                  2753263969876,
                  2767546148289,
                  2781866261445,
                  2796227485100,
                  2810621894534,
                  2825049920451,
                  2839522733654,
                  2854027078942,
                  2868569259807,
                  2883151700594,
                  2897766520286,
                  2912419613352,
                  2927112003870,
                  2941838329622,
                  2956602060545,
                  2971405516422,
                  2986242978616,
                  3001117524512,
                  3016031742517,
                  3030980206443,
                  3045965240341,
                  3060992277046,
                  3076048820693,
                  3091145902698,
                  3106282528142,
                  3121452473721,
                  3136658491251,
                  3151905731105,
                  3167186887389,
                  3182504695087,
                  3197862957852,
                  3213254978334,
                  3228683308253,
                  3244152304423,
                  3259655033342,
                  3275194456893,
                  3290774247911,
                  3306387531518,
                  3322037893431,
                  3337729281347,
                  3353452618902,
                  3369214681620,
                  3385017695174,
                  3400850176205,
                  3416722474015,
                  3432635829873,
                  3448582258120,
                  3464565311540,
                  3480588385263,
                  3496644940477,
                  3512738789372,
                  3528874103718,
                  3545040091820,
                  3561246315352,
                  3577490676611,
                  3593768746851,
                  3610085450934,
                  3626441045388,
                  3642830545292,
                  3659256916613,
                  3675724922558,
                  3692223908106,
                  3708761701380,
                  3725340388142,
                  3741950109304,
                  3758598534817,
                  3775288110658,
                  3792010806853,
                  3808768255741,
                  3825567842261,
                  3842400892301,
                  3859270994228,
                  3876182257554,
                  3893125821610,
                  3910106630253,
                  3927128404395,
                  3944182735083,
                  3961273865373,
                  3978406170099,
                  3995570819031,
                  4012773531703,
                  4030018284690,
                  4047294242987,
                  4064607085413,
                  4081962615738,
                  4099348456122,
                  4116772954700,
                  4134237907398,
                  4151735224562,
                  4169270490068,
                  4186846497562,
                  4204455615471,
                  4222101738710,
                  4239789614309,
                  4257508561494,
                  4275265526839,
                  4293062819074,
                  4310893414713,
                  4328761778121,
                  4346668298410,
                  4364611215755,
                  4382589275244,
                  4400609717591,
                  4418661277080,
                  4436750710090,
                  4454881698143,
                  4473043446311,
                  4491244587277,
                  4509486323407,
                  4527761014659,
                  4546070923580,
                  4564423485376,
                  4582809027275,
                  4601230561151,
                  4619694430129 };
